-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add depends_on :linux and :macos #3270
Conversation
@@ -108,7 +108,8 @@ def parse_symbol_spec(spec, tags) | |||
case spec | |||
when :x11 then X11Requirement.new(spec.to_s, tags) | |||
when :xcode then XcodeRequirement.new(tags) | |||
when :macos then MinimumMacOSRequirement.new(tags) | |||
when :linux then LinuxRequirement.new | |||
when :macos then tags.empty? ? MacOSRequirement.new : MinimumMacOSRequirement.new(tags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make MacOSRequirement.new
handle the tags.empty?
case instead of having the meaning overloaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
How do you specify both that macOS is required and that a minimum version is required? My understanding is |
To specify that both that macOS is required and that a minimum version is required:
|
That seems like pretty yucky syntax to me. |
c82d73b
to
eb3ba7c
Compare
super | ||
end | ||
|
||
satisfy(build_env: false) { MacOS.version >= @version } | ||
satisfy(build_env: false) do | ||
if @version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
next false if !OS.mac? || !@version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be worth taking the same approach below, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks for the suggestion, Mike. The logic needed tweaking. When OS.mac?
is true
and @version
is nil
, the result should be true
.
@@ -3,18 +3,32 @@ | |||
class MinimumMacOSRequirement < Requirement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth renaming this now to be consistent, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the class is a component of the DSL. The name MinimumMacOSRequirement
is used by two formulae in core:
nordugrid-arc.rb: depends_on MinimumMacOSRequirement => :yosemite
phantomjs.rb: depends_on MinimumMacOSRequirement => :lion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add it to compat
and update them to use depends_on :macos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Would you like to suggest a name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MacOSRequirement
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed MinimumMacOSRequirement
to MacOSRequirement
and added MinimumMacOSRequirement
to compat
.
eb3ba7c
to
fa05a65
Compare
@@ -0,0 +1,3 @@ | |||
require "requirements/macos_requirement" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stick this file's contents in homebrew/Library/Homebrew/compat/requirements.rb
fatal true | ||
|
||
def initialize(tags = []) | ||
@version = MacOS::Version.from_symbol tags.first unless tags.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MacOS::Version.from_symbol(tags.first)
just to aid visual parsing.
|
||
satisfy(build_env: false) do | ||
next false if !OS.mac? && !@version | ||
next true if !OS.mac? || !@version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little hard to parse above. Can you maybe make it if
/else
s? This may contradict what I said earlier: sorry!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factoring out the minimum_version?
utility method also helped make this logic more clear.
end | ||
|
||
def message | ||
return "macOS is required." if !OS.mac? || !@version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if !OS.mac? || !@version
could be a utility method, I think, it's repeated 3 times.
67dd0a3
to
9cccda7
Compare
super | ||
end | ||
|
||
def minimum_version? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minimum_version_provided
or passed
or specified
something would be nicer to make it clear that this doesn't mean the minimum version is met.
Tests failing on Linux (shouldn't assume |
9cccda7
to
88e0501
Compare
Fixed up. |
@sjackman Still got 🔴. |
88e0501
to
507f248
Compare
😬 |
Good to merge? |
end | ||
|
||
satisfy(build_env: false) do | ||
next OS.mac? || @version unless minimum_version_specified? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, last nite: can you split this into two next
checks and return a boolean value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Move MinimumMacOSRequirement to compat.
507f248
to
230c87a
Compare
Thanks @sjackman and sorry for the nit picking! |
No worries. Thanks for merging, Mike. |
brew tests
with your changes locally?Allow a formula to declare whether it depends on macOS or Linux.